import unittest,time
from re import search
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver import Keys

class A3malllogin(unittest.TestCase):
    #启动
    def setUp(self) -> None:
        self.driver=webdriver.Firefox()
        self.driver.get('')
        self.driver.maximize_window()
        time.sleep(3)
    #关闭
    def tearDown(self) -> None:
        time.sleep(3)
        self.driver.quit()

    #开始执行用例
    def test_a3mall_login(self):
        self.driver.find_element(By.XPATH, '/html/body/div[1]/div/div[2]/ul/li[1]/a').click()
        time.sleep(3)
        # 断言1：断言文本：会员登陆
        dy1 = self.driver.find_element(By.CLASS_NAME, 'reg-new').text
        print("文本断言3，会员登陆:", dy1)
        time.sleep(2)
        # 用户名  密码
        self.driver.find_element(By.NAME, 'username').send_keys('13811033962')
        time.sleep(3)
        self.driver.find_element(By.NAME, 'password').send_keys("123456")
        time.sleep(8)
        # 登录按钮
        self.driver.find_element(By.XPATH, '//*[@id="theForm"]/div[5]/a').click()
        time.sleep(5)
        # 断言2：断言文本：欢迎回来，13811033962
        dy2 = self.driver.find_element(By.XPATH, '/html/body/div[1]/div/div[2]/ul/li[1]/a').text
        print("文本断言2，欢迎回来，13811033962:", dy2)
        time.sleep(2)
        # 断言3：断言文本：账户余额：¥ 988389770.25  中的 988389770.25
        dy3 = self.driver.find_element(By.XPATH, '/html/body/div[5]/div[2]/div[1]/div[2]/div[2]/ul/li[4]').text
        dy31 = dy3.replace('¥ ', '')
        print("文本断言3，账户余额:", dy31)
        time.sleep(2)
